<template>
	<view class="wap">
		<navbar :parameter='parameter'></navbar>
		<view class="box">
			<view class="title-line">{{details.name}}</view>
			<view class="details-box">
				<u-parse :content="details.content"></u-parse>
			</view>
		</view>
		<view class="bottom-box acea-row row-between-wrapper">
			<view class="total">
				费用:<text>￥{{details.price}}元</text>
			</view>
			<view @click="payment" class="order-btn">立即购买</view>
		</view>
		<login :isAuto="false" ref="mySon" @phone_show="phone_show"></login>
		<phone :isShow="isShow2" @close="close2" @chamgs="chamgs2"></phone>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				parameter: {
					'navbar': '1',
					'return': '1',
					'title': '体检套餐详情',
					'color': true,
					'class': 'on'
				},
				details: {},
				isShow2: false,
				id: '',
			};
		},
		onLoad(option) {
			console.log(option)
			this.id = option.id
			this.physicalInfo(option.id);
			let pages = getCurrentPages();
			if (pages[pages.length - 2]) {
				//如果有上一页，就返回上一页
				this.parameter.return = '1';
			} else {
				this.parameter.return = '2';
			}

		},
		onShow() {

		},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {
			return {
				path: '/pages/index/physical_examination/details?id=' + this.id,
			}

		},
		onShareTimeline(res) { //分享到朋友圈
			return {
				path: '/pages/index/physical_examination/details?id=' + this.id,
			}

		},
		methods: {
			async physicalInfo(id) {
				const res = await this.$myRequest({
					url: '/api/product/physicalInfo',
					data: {
						id: id
					}
				})
				console.log(res.data.data)
				this.details = res.data.data;
				this.details.type = 1;
			},

			phone_show() {
				this.isShow2 = true;
			},
			close2() {
				this.isShow2 = false

			},
			payment() {
				var openid = uni.getStorageSync('openid');
				if (openid) {
					uni.navigateTo({
						url: "/pages/index/form/mechanism_form?type=" + 1 + '&id=' + this.details.id + '&price=' +
							this.details.price
					})
				} else {
					this.$refs.mySon.login();
				}


			}
		}
	}
</script>


<style lang="scss" scoped>
	.wap {
		padding: 30rpx;
		padding-bottom: 80rpx;
	}

	.box {
		width: 100%;
		border-radius: 20rpx;
		background-color: #fff;
		margin-bottom: 30rpx;
		padding: 30rpx;
	}

	.title-line {
		color: #000406;
		font-size: 33rpx;
		font-weight: 700;
		margin-bottom: 20rpx;
	}

	.details-box {
		margin-bottom: 30rpx;
	}


	.bottom-box {
		width: 100%;
		position: fixed;
		left: 0;
		bottom: 0;
		background-color: #fff;
		padding: 0 30rpx;
		height: 120rpx;
		z-index: 10;
	}

	.bottom-box .total text {
		color: #FF4242;
	}

	.bottom-box .order-btn {
		width: 250rpx;
		height: 70rpx;
		background: #347DFE;
		border-radius: 10px;
		color: #fff;
		text-align: center;
		line-height: 70rpx;
	}
</style>
